<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% String path = request.getContextPath();
	String basePath = request.getScheme()+"://" +request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="<%=basePath%>"/>
<title>商品类型的页面</title>
<link href="css/backstyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){
  $(".click").click(function(){
  $(".tip").fadeIn(200);
  });
  
  $(".tiptop a").click(function(){
  $(".tip").fadeOut(200);
});

  $(".sure").click(function(){
  $(".tip").fadeOut(100);
});

  $(".cancel").click(function(){
  $(".tip").fadeOut(100);
});
});
</script>
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function (){
        //给全选按钮绑定改变事件
        $("#checkedAll").change(function (){
            //获得全选按钮的状态
            var status = $(this).prop("checked");
            //改变每条记录的按钮的状态和全选按钮一致
            $(".checkedOne").each(function (){
                $(this).prop("checked",status);
            })
        })
        //给删除选中绑定点击事件
        $("#delChecked").click(function (){
            //创建一个数组存放选中的id
            var array = new Array();
            //获取所有选中的多选框中的id
            $(".checkedOne:checked").each(function (){
                var id = $(this).val();
                //将id放进数组中
                array.push(id);
            })

            if(array.length == 0){
                alert("请先选择要删除的商品类型！")
                return;
            }else{
                //提示用户是否删除
                if(confirm('确认删除所选用户信息')){
                    //用ajax传输要删除的用户
                    $.ajax({
                        url:"ProductTypeController/delChecked",//删除选中
                        type:"post",
                        data:JSON.stringify(array),//将传输的数据转化为JSON格式
                        dataType:"JSON",//期待服务器返回的数据类型
                        contentType:"application/json",//接收的数据以json格式解析（指定响应的内容）
                        success:function(data){
                            if(data.code == 200){
                                //转跳到商品类别列表
                                location.href="ProductTypeController/selectPage";
                            }else{
                                alert("删除失败！");
                                window.location.reload();
                            }
                        }
                    })
                }
            }
        })


    })
</script>
</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">数据表</a></li>
    <li><a href="#">基本内容</a></li>
    </ul>
    </div>
    
    <div class="rightinfo">
    
    <div class="tools">
    
    	<ul class="toolbar">
        <li>
            <a href="back/goodstype/goodsadd.jsp"/><span><img src="images/t01.png" /></span>添加</a>
        </li>
        <li id="delChecked">
            <a ><span><img src="images/t03.png" /></span>删除选中</a>
        </li>
        </ul>
        <ul class="toolbar1">
        <li><span><img src="images/t05.png" /></span>设置</li>
        </ul>
    
    </div>
    
    
    <table class="tablelist">
    	<thead>
	    	<tr>
	        <th><input id="checkedAll" type="checkbox" />全选</th>
	        <th>商品类别编号<i class="sort"><img src="images/px.gif" /></i></th>
	        <th>商品类别名称</th>
	        <th>父类编号</th>
	        <th>操作</th>
	        </tr>
        </thead>
        <tbody>
            <c:forEach items="${requestScope.page.list}" var="p">
                <tr>
                    <td><input class="checkedOne" type="checkbox" value="${p.id}" /></td>
                    <td>${p.id}</td>
                    <td>${p.name}</td>
                    <td>${p.pid}</td>
                    <td>
                        <a href="ProductTypeController/getProductTypeById?id=${p.id}">编辑</a>
                        <a href="ProductTypeController/deleteProductTypeById?id=${p.id}" onclick="return confirm('是否确认删除？')">删除</a>
                    </td>
                </tr>
            </c:forEach>

        </tbody>
    </table>
        <jsp:include page="/back/common/page.jsp"/>
   
 
    
    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>
        
      <div class="tipinfo">
        <span><img src="images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认对信息的修改 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>
        
        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>
    
    </div>
    
    </div>
    
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>

<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>
</body>
</html>

